package com.gomtel.smartdevice.ui.holder;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.gomtel.smartdevice.R;
import com.gomtel.smartdevice.base.BasicHolder;
import com.gomtel.smartdevice.global.WatchApplication;
import com.gomtel.smartdevice.moudle.db.entity.PulseConditionBean;

/**
 * Created by Administrator on 2018/7/19 0019.
 */

public class PulseConditionHolderLJF extends BasicHolder<Object> {

    private Context context;
    private PulseConditionBean pulseConditionBean;
    private ImageView type;
    private ImageView pulseStatusType;
    private TextView fitnessType;
    private TextView open_about;

    public PulseConditionHolderLJF(Context context) {
        this.context = context;
    }

    @Override
    public View initHolderView() {
        View view = View.inflate(WatchApplication.getInstance(), R.layout.item_pluse_condition_ljf, null);
        type = (ImageView) view.findViewById(R.id.type);
        pulseStatusType = (ImageView) view.findViewById(R.id.pulseStatusType);
        fitnessType = (TextView) view.findViewById(R.id.fitnessType);
        open_about = (TextView) view.findViewById(R.id.open_about);
        return view;
    }

    @Override
    public void bindData(Object data) {
        pulseConditionBean = (PulseConditionBean) data;
        setStatus(pulseConditionBean.getMaili());
        fitnessType.setText(" 脉理:" + pulseConditionBean.getPingji());
        setType(pulseConditionBean.getType());
    }

    private void setType(String type_mai) {
        if (type_mai != null) {
            switch (type_mai) {
                case "xin":
                    type.setImageResource(R.drawable.xinmai);
                    break;
                case "gan":
                    type.setImageResource(R.drawable.ganmai);
                    break;
                case "shen":
                    type.setImageResource(R.drawable.shenmai);
                    break;
            }
        }
    }

    private void setStatus(String status) {
        if (status != null) {
            switch (status) {
                case "弱脉":
                    pulseStatusType.setImageResource(R.drawable.ruo);
                    break;
                case "缓脉":
                    pulseStatusType.setImageResource(R.drawable.huan);
                    break;
                case "玄脉":
                    pulseStatusType.setImageResource(R.drawable.xuan);
                    break;
                case "紧脉":
                    pulseStatusType.setImageResource(R.drawable.jin);
                    break;
                case "实脉":
                    pulseStatusType.setImageResource(R.drawable.shi);
                    break;
            }
        }
    }
}
